// var api = "http://songyujianiu.qicp.vip/";
var api = "http://localhost:9000";
var app = new Vue({
	el: "#app",
	data: function() {
		return {
			cronlist: "",
			loginName: "2222",
			password: "",
		};
	},
	created: function() {
		// this.test()
		// layer.msg("用户名不能为空", { time: 1000 });
		const par = new URLSearchParams();
		// par.append("loginName", that.loginName);
		// par.append("password", that.password);
		// var that = this
		axios({
			method: "post",
			url: api + "/quartz/list",
			params: par,
		}).then(function(res) {
			// console.log(res);
			if (res.data.code == "101") {
				// layer.msg("注册成功", { time: 1000 });

				app.cronlist = res.data.data;
				console.log(res.data.data);
				// that.$message({
				// 	type: "success",
				// 	message: res.data.message,
				// });
				// window.location.href = "001.html";
			} else {
				// that.$message({
				// 	type: "error",
				// 	message: res.data.message,
				// });
				// alert(res.data.message);
				layer.msg(res.data.message, {
					time: 1000
				});
			}
		});
	},
	methods: {
	
		//
		// 保存
		start: function(triName) {
			// alert(triName)
			let that = this;
			const par = new URLSearchParams();
			par.append("triName", triName);
			// par.append("password", that.password);
			axios({
				method: "post",
				url: api + "/quartz/start",
				params: par,
			}).then(function(res) {
				console.log(res);
				if (res.data.code == "101") {
					// alert("注册成功");
					layer.msg("启动成功", {
						time: 1000
					});
					
				} else {
					layer.msg(res.data.message, {
						time: 7000
					});
				}
			});
		},
		clone: function(triName) {
			let that = this;
			
			const par = new URLSearchParams();
			par.append("triName", triName);
			// par.append("password", that.password);
			axios({
				method: "post",
				url: api + "/quartz/clone",
				params: par,
			}).then(function(res) {
				console.log(res);
				if (res.data.code == "101") {
					layer.msg("关闭成功", {
						time: 1000
					});
					
				} else {
					console.log(res.data.message)
					layer.msg(res.data.message, {
						time: 6000
					});
				}
			});
		},
		rechange: function(triName) {
			window.localStorage.setItem('triName', '');
			window.localStorage.setItem('triName', triName);
			
			layer.open({
			  type: 2
			  ,area:['600px','200px']
			  ,content: 'changCron.html'
			});  
		
			
		},
		add(){
			window.location.href="cronAdd.html";
		},
		//  弹出框的全选
		handleSelectionChange(val) {
			console.log(val);
			var arr = [];
			let that = this;
			for (const item in val) {
				arr.push(val[item].userId);
			}
			that.userId = arr;
		},
		//  分页
		handleSizeChange(val) {
			console.log(`每页 ${val} 条`);
		},
		handleCurrentChange(val) {
			console.log(`当前页: ${val}`);
		},
	},
});
